<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>扩展运算符应用</title>
  </head>
  <body>
    <div></div>
    <div></div>
    <div></div>
    <script>
      // 1.数组的合并
      const arr1 = [1, 2, 3];
      const arr2 = [4, 5, 6];

      // ES5
      const newAarr1 = arr1.concat(arr2);
      console.log(newAarr1);

      // 扩展运算符
      const newArr2 = [...arr1, ...arr2];
      const newArr3 = Array.of(...arr1, ...arr2);
      // Array.of() 会把参数转成数组
      console.log(newArr2, newArr3);

      // 2.数组的克隆
      const sanzhihua = ["E", "G", "M"];
      const sanzhicao = [...sanzhihua]; // 浅拷贝
      console.log(sanzhicao);

      // 3. 将伪数组转为真正的数组
      const divs= document.querySelectorAll('div');
      console.log(divs); // [ovject] NodeList(3) [div, div, div]
      const divArr = [...divs] 
      console.log(divArr); 
    </script> 
  </body>
</html>
